<%--
Created by IntelliJ IDEA.
User: zhangyuan
Date: 2020-04-08
Time: 14:56
To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>新建工作</title>
    <link rel="stylesheet" type="text/css" href="/css/main/theme3/fontawesome5.min.css"/>
    <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
    <link rel="stylesheet" href="/lib/pagination/style/pagination.css">
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
    <link rel="stylesheet" href="/css/base.css">
    <link rel="stylesheet" type="text/css" href="/css/base/base.css?20201106.1" />
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
    <link rel="stylesheet" href="/css/workflow/flowrun/allsearch.css">
    <script src="/js/common/language.js"></script>
    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/js/jquery/jquery.cookie.js"></script>
    <script src="/lib/layer/layer.js?20201106"></script>
    <script src="/js/base/base.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script type="text/javascript" src="/js/base/tablePage.js"></script>
    <script src="/lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <style>

		.moduleHeader{
			font-size:14px!important;
		}
        #headerbox{
            height: 43px;
            line-height: 43px;
        }
        #headerbox .title{
            margin-left: 22px;
            height: 43px;
        }
        #headerbox .title img{
            margin-bottom: 5px;
        }
        #headerbox span{
            float: none;
            display: inline-block;
            height: 43px;
            line-height: 43px;
        }
        .headerTitle{
            margin-left: 5px;
            font-size: 22px;
            color: #333;
            line-height: 18px;
        }
        .color2 {
            color: #50C625;
        }
        .color3 {
            color: #F4A8BD;
        }
        table tr{
            border: none;
        }
        body{
            background: #f6f7f9;
        }
        .head{
            height: auto;
            border: none;
        }
        .tablebox{
            margin-left: -6px;
			margin-top : 28px;
        }
    </style>
    <style>
        .tab_c{
            background: #f5f5f5;
            border-right: 2px solid #e9f0f5;
        }
        .tab_cone{
            color: #111!important;
        }
        .one_all{
            border: none;
            border-bottom: none;
            background: #f5f7f8 !important;
            border-top: 2px solid #fff!important;
        }
        .one_logo {
            margin-left: 0;
            margin-top: 0;
            float: none;
        }
        .tab_cone .one:nth-child(1) {
            border-top: none;
        }
    </style>
    <style type="text/css">
        #flow_sort_nav > a{
            text-decoration:none;
            color:#666666;
            font-size: 18px;
            font-weight:bold;
        }
        #flow_sort_nav > a:hover {
            text-decoration: none;
            color: #589Fff;
            font-weight: bold;
        }
    </style>
    <style type="text/css">
        .container-fluid{
            width: 100%;
            height:100%;
            overflow:hidden;
        }
        .cont_left{
            background: none !important;
            border-right: none;
        }
        .all_ul{
            width: 100% !important;
            height: 100%;
            margin-left: 0% !important;
            background: #fff;
        }
        .tab_c{
            margin-left: 0% !important;
        }
        .one_all{
            height: 40px !important;
            width: 100% !important;
            border-left: none !important;
            border-right: none !important;
        }
        .one_name{
            margin-left: 5px;
            width: 77%;
            line-height: 40px !important;
            text-align: left;
            color: #333;
            padding-left: 10px;
            text-overflow: inherit;
        }
        .one_name img{
            margin-left: 2px;
        }
        .down_jiao{
            margin-left: 0;
            position: absolute;
            right: 5px;
            margin-top: 15px;
            width: 12px;
            height: 7px;
        }
        .two_all{
            width: 100%;
        }
        #title{
            padding-left: 20px;
        }

        .two_all h1{
            width: 66%;
            margin-left: 0;
            color: #111;
            text-shadow: none;
            padding-left: 55px;
        }

        .cont_left{
            width:15%;
        }
        .cont_rig{
            width:85%;
        }
        .rig_all{
            width:96%;
            height:100%;
            margin:auto;
        }
        .rig_cont ul li{
            width: 99%;
            height: 80px;
            border: 1px solid #cccccc;
            border-radius: 2px;
            background: #f9fbff;
            margin-top: 10px;
        }
        .rig_cont{
            overflow-y: scroll;
            height: 94%;

        }
        .rig_title img,.rig_title h1{
            float:left;
            margin-top:5px;
        }
        .rig_title img{
            margin-top:10px;
        }
        .rig_title h1{
            font-size: 15pt;
            font-weight: normal;
            font-family: Microsoft yahei,Helvetica Neue,Helvetica,PingFang SC,Tahoma,Arial,sans-serif;
            margin-left: 12px;
            line-height: 35px;
        }
        .rig_left,.rig_mid,.rig_rig{
            float: left;
            height: 100%;
        }
        .rig_rig{
            width:27%;
            font-size: 17px;
        }
        .rig_left{
            /*width: 55%;*/
            width: 100%;
            font-size: 14px;
            padding-left: 25px;
            margin-top: 5px;

        }
        .rig_mid{
            width:18%;
            margin-top: -27px;
        }
        .liucheng,.liucheng1,.liucheng2{
            height:100%;
            float: left;
            margin-right:7%;
            cursor: pointer;
        }
        .liucheng img,.liucheng h1,.liucheng1 img,.liucheng1 h1,.liucheng2 img,.liucheng2 h1{
            float:left;
        }
        .rig_rig div{
            width: 49%;
            float: left;
            margin-top: 14px;
            cursor: pointer;
        }
        .xinjian_img{
            margin-left: 39%;
            cursor: pointer;
        }
        .xinjian_h1{
            width: 100%;
            height: 20px;
            text-align: center;
        }
        .rig_left h1{
            font-size: 13pt;
            font-weight: bold;
            margin-left: 12px;
            margin-top: 17px;
            width: 90%;
            overflow: hidden;
            text-overflow:ellipsis;
            white-space: nowrap;
        }
        .rig_left h1:hover{
            color: #2b7fe0;
        }
        .rig_left h2{
            margin-left: 12px;
            color: #b7b8b9;
            margin-top: 5px;
            width:90%;
            overflow: hidden;
            text-overflow:ellipsis;
            white-space: nowrap;
        }
        .liucheng h1,.liucheng1 h1,.liucheng2 h1{
            line-height: 80px;
            margin-left: 5px;
        }
        .liucheng img,.liucheng1 img,.liucheng2 img{
            margin-top: 31px;
        }
        .new_work{
            font-size: 22px;
            margin-top: 9px;
        }
        .new-search{
            margin-top:8px !important;
        }
        .one_all{
            background: #f0f4f7 !important;
            position: relative;
        }
        .one_alltwo{
            background: #fff!important;
            height: 40px !important;
            width: 100% !important;
            border-left: none !important;
            border-right: none !important;
            border: none;
            border-bottom: none;
            border-top: 2px solid #fff!important;
            margin-top: 0%;
        }
        .one_alltwo h1{
            font-size: 18px;
            color: #2f8ae3;
        }
        .tab_cone li .one_all:hover{
            background: #b6e0ff !important;
        }
        .tab_cone{
            width: 100% !important;
            height:99% !important;
        }
        .er_img {
            margin-left: 0;
            position: absolute;
            right: 15px;
            margin-top: 15px;
            width: 12px;
            height: 7px;
        }
        #searchbtn,.rig_mid h1,.rig_rig h1{
            cursor: pointer;
			height:30px;
        }
        .namenew{
            cursor: pointer;
            width: 254px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            display: inline-block;
        }
        /*定义滚动条宽高及背景，宽高分别对应横竖滚动条的尺寸*/
        .rig_cont::-webkit-scrollbar{
            width: 0px;
            height: 16px;
            background-color: #f5f5f5;
        }
        /*定义滚动条的轨道，内阴影及圆角*/
        .rig_cont::-webkit-scrollbar-track{
            -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
            border-radius: 10px;
            background-color: #f5f5f5;
        }
        /*定义滑块，内阴影及圆角*/
        .rig_cont::-webkit-scrollbar-thumb{
            /*width: 10px;*/
            height: 20px;
            border-radius: 10px;
            -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
            background-color: #555;
        }

        #sort_cont li:hover{
            background: #e8f4fc;
        }
        .quick:hover .xinjian_h1{
            color:#2b7fe0;
        }

        .xiangdao:hover h1{
            color:#2b7fe0;
        }
        .xjxd{
            cursor: pointer;
        }
        #form_select{
            height: 28.4px !important;
        }
        /*一级菜单移入移出样式的改变*/
        .one_all li:hover{
            background:#ccebff;
            cursor:pointer;
        }
        .one_all li:hover h1{
            color:#2f8ae3;
        }
        /*二级菜单移入移出样式的改变*/
        /* .two_menu li:hover{
             background:#ccebff;
             cursor:pointer;
         }
         .two_menu li:hover h1{
             color:#2f8ae3;
         }*/
        .two .two_all:hover{
            color:#2f8ae3;
            background:#ccebff;
            cursor: pointer;
        }
        .menu_change{
            color:#2f8ae3;
        }
        /*三级菜单移入移出样式的改变*/
        .three:hover{
            color:#2f8ae3;
            background:#ccebff;
        }
        .rig_mid h1{
            font-size:16px;
        }
        .rig_mid h1:hover{
            color: #2b7fe0;
        }
        /* .liucheng img, .liucheng1 img, .liucheng2 img{
             margin-top:35px;
         }*/
        .sanji_circle{
            display: none;
        }
        .three{
            background: rgb(232, 244, 252);
        }
        .three h1{
            color: #333;
            text-shadow: none;
        }
        .sanji .three:hover{
            background: #ccebff;
        }
        .two{
            background: none!important;
        }

        /*********************左侧滚动条修改******************************/
        .yiji::-webkit-scrollbar {
            width: 10px;
        }
        .yiji::-webkit-scrollbar-thumb {
            border-radius: 50px;
            background-color: #bfbfbf;
        }
        .yiji::-webkit-scrollbar-track {
            border-radius: 50px;
            background-color: #ffffff;
        }
        .one{
            background: #fff!important;
        }
        .sort_new{
            overflow: hidden;
            margin: 0px auto;
			border-bottom: 1px solid #f0f0f0;
        }
        .rig_rig{
            margin-top: -12px;
            font-size: 13px;
        }
        .toggle{
            width: 80px;
            height: 27px;
            margin-top: 9px;
            margin-left: 30px;
            background: #4d90fe;
            color: white;
            border-radius: 12px;
            border: none;
        }
        .cover_scroll {
            position: absolute;
            top: 0;
            right: 0px;
            height: 100%;
            width: 25px;
            z-index: 1;
            background-color: #fff;
        }

        .moduleHeader .text::before {
            content: '\f0e8';
            color: #2b7fe0;
            font-family: "Font Awesome 5 Pro";
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            display: inline-block;
            font-style: normal;
            font-variant: normal;
            font-weight: 900;
            line-height: 1;
            margin-right: 4px;
        }

    </style>
    <link rel="stylesheet" href="/css/workflow/work/switchWork.css">
</head>
<body>
<%--<button class="toggle">切换视图</button>--%>
<div class="tablebox" style="display: block;position: relative">
    <div width="99%" style="margin-top:10px;" id="div-table-1">
    </div>
</div>
<script>

    //点击表单新建工作
    function newWorkFlow(flowId,cb){
        $.ajax({
            url:'../../workflow/work/workfastAdd',
            type:'get',
            dataType:'json',
            data:{
                flowId:flowId,
                prcsId : 1,
                flowStep : 1,
                runId:'',
                preView:0
            },
            async: false,//同步请求,这里使用ajax必须使用同步方式请求，因为浏览器认为这种打开在ajax后新页面是不安全的
            success:function(res){
                if(res.flag==true){
                    var data = res.object;
                    cb(data);
                }
            }
        });
    }



    //打开工作层级
    function openWork(sortId,me) {
        if($(me).next().find('.isClick').length==0){
            $.ajax({
                url:'../../flow/flowAuthOrSearch',
                type:'get',
                dataType:'json',
                data:{
                    sortId:sortId
                },
                success:function(obj) {
                    if (obj.flag) {
                        var data = obj.obj;
                        var str = '';
                        renderData(data, me, sortId);
                    } else {
                        $("#module_" + sortId + "").addClass("enpty_body")
                    }
                }
            })
        }

    }
    //打开相应层级工作后插入表单
    function renderData(data,me,sortId) {
        var str='';
        for(var i=0;i<data.length;i++){
            if(data[i].runName){
                str+='<div class="sort_new" tid='+data[i].flowId+' tableName="'+data[i].sortMainType+'" formId='+data[i].formId+' sortId='+data[i].flowSort+' freePreset="'+ data[i].freePreset +'" forcePreSet="'+ data[i].forcePreSet +'"><div class="rig_left">'+
                    '<b></b><div flowId='+data[i].flowId+' class="namenew" newType="'+function(){
                        if(data[i].newType != undefined && data[i].newType.indexOf('0')<0){
                            return '1'
                        }else{
                            return '0'
                        }
                    }()+'" title="'+data[i].flowName+'">'+data[i].flowName+'</div></div>'+

                    '</div>'
            }else{
                str+='<div class="sort_new" tid='+data[i].flowId+' tableName="'+data[i].sortMainType+'" formId='+data[i].formId+' sortId='+data[i].flowSort+' freePreset="'+ data[i].freePreset +'" forcePreSet="'+ data[i].forcePreSet +'"><div class="rig_left">'+
                    '<b></b><div flowId='+data[i].flowId+' class="namenew" newType="'+function(){
                        if(data[i].newType != undefined && data[i].newType.indexOf('0')<0){
                            return '1'
                        }else{
                            return '0'
                        }
                    }()+'" title="'+data[i].flowName+'">'+data[i].flowName+'</div></div>'+
                    '</div>'
            }
        }
        $("#ul-body"+sortId+"").html(str);
    }


    $(function(){

        $.ajax({
            url:"/workflow/flowclassify/flowByAuth",
            type:'post',
            dataType:'json',
            success:function(res){
                console.log(res)
                //要筛选层级
                var first = res.datas
                //有下一级的层级
                var cenJi = []
                //最终层级
                var last = []
                var i=0;
                for (i; i < first.length; i++) {
                    //是否有下一个层级
                    if (first[i].childs.length !=0) {

                        cenJi=cenJi.concat(first[i].childs)
                    }else{
                        last[last.length]=first[i];
                    }
                    //当前层级筛选完进行下一层筛选
                    if(first.length-1==i){
                        //是否还有层级要筛选
                        if(cenJi.length !=0){
                            first=[].concat(cenJi);
                            i=-1;
                            cenJi=[];
                            continue;
                        }else {
                            break;
                        }

                    }
                }

                for(var b=0;b<last.length;b++){
                    var str_left = '<div id="module_'+ last[b].sortId +'" class="module color_style_4 listColor'+last[b].sortId+'">\
                                            <div class="head" class="isClick" onclick="openWork('+last[b].sortId+',this)" >\
                                                <h4 id="module_'+ last[b].sortId +'_head" class="moduleHeader">\
                                                    <span id="module_'+ last[b].sortId +'_text" class="text">'+ last[b].sortName +'</span>\
                                                </h4>\
                                            </div>\
                                            <div id="module_'+ last[b].sortId +'_body" class="module_body" >\
                                                <div id="module_'+ last[b].sortId +'_ul" class="module_div">\
                                                    <ul id="ul-body'+last[b].sortId+'"></ul>\
                                                </div>\
                                            </div>\
                                        </div>';
                    $("#div-table-1").append($(str_left))
                }
                $('.text').each(function () {

                    $(this).click()

                })

            }
        })
    })



    //点击名称快速新建页面
    $(document).on('click','.namenew',function(){
        var _this = $(this);
        var newType = $(this).attr('newType');
        var forcePreSet = _this.parents('.sort_new').attr('forcePreSet')||'';
        var freepreset = _this.parents('.sort_new').attr('freepreset')||'';
        var tableName = _this.parents('.sort_new').attr('tableName')||'';
        if(freepreset == '1'&&(forcePreSet == '2'||forcePreSet == '3'||forcePreSet == '4')){
            if(forcePreSet == '2'){
                var calc = '此工作要求强制输入前缀，确定进入新建向导？';
            }else if(forcePreSet == '3'){
                var calc = '此工作要求强制输入后缀，确定进入新建向导？';
            }else if(forcePreSet == '4'){
                var calc = '此工作要求强制输入前缀和后缀，确定进入新建向导？';
            }
            $.ajax({
                url:'/userCountPer',
                dataType:'json',
                type:'get',
                success:function(res){
                    if(res.flag){
                        var flowId=_this.attr('flowId');
                        if(tableName == 'BUDGETTYPE'){
                            $.popWindow("/workflow/work/newflowguider?flowId="+flowId+'&flowStep=1&tableName=budget&prcsId=1','<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
                        }else{
                            $.popWindow("/workflow/work/newflowguider?flowId="+flowId+'&flowStep=1&prcsId=1','<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
                        }

                    }else{
                        $.layerMsg({content:'人数达到上限，不能新建',icon:6})
                    }
                }
            })
        }else{
            $.ajax({
                url:'/userCountPer',
                dataType:'json',
                type:'get',
                success:function(res){
                    console.log(123);
                    if(res.flag){
                        var flowId= _this.attr('flowId');
                        user_id='quick';
                        if(newType == '0'){
                            newWorkFlow(flowId,function (data) {
                                if(data.sortMainType=='BUDGETTYPE'){
                                    parent.location.href="/workflow/work/workform?flowId="+flowId+'&type=new&flowStep=1&prcsId=1&tableName=budget&runId='+data.flowRun.runId;
                                    //$.popWindow("/workflow/work/workform?flowId="+flowId+'&type=new&flowStep=1&prcsId=1&tableName=budget&runId='+data.flowRun.runId,'<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
                                }else{
                                    parent.location.href="/workflow/work/workform?flowId="+flowId+'&type=new&flowStep=1&prcsId=1&runId='+data.flowRun.runId;
                                    //  $.popWindow("/workflow/work/workform?flowId="+flowId+'&type=new&flowStep=1&prcsId=1&runId='+data.flowRun.runId,'<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
                                }

                            })
                        }

                    }else{
                        $.layerMsg({content:'人数达到上限，不能新建',icon:6})
                    }
                }
            })
        }



    });

    $(document).on("mouseenter mouseleave",".sort_new",function () {
        $(this).find("b").toggleClass("b")
    })

    //点击流程设计图
    $(document).on('click','.liucheng',function(){
        var flowId=$(this).attr('flowId');
        window.open('/flowSetting/processDesignToolsT?flowId='+flowId+'&type=0','流程设计器预览','width='+(window.screen.availWidth)+',height='+(window.screen.availHeight)+',top=0,left=0,scrollbars=no,resizable=no');
    })
    //点击流程表单
    $(document).on('click','.liucheng1',function(){
        var flowId= $(this).attr('flowId');
        var formId=$(this).parents('.sort_new').attr('formid');
        user_id='quick';
        $.popWindow('/workflow/work/workform1?formId='+formId,'<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
    })
    //点击流程说明
    $(document).on('click','.liucheng2',function(){
        var flowId=$(this).parents('.sort_new').attr('tid');
        var formId=$(this).parents('.sort_new').attr('formid');
        var word=$(this).parent().siblings('.rig_left').find('h1').text();
        $.popWindow("/workflow/work/processSpeak?flowId="+flowId+'&formId='+formId,'流程说明-'+word+'','0','0','1150px','700px');
    })
    //点击出现快速新建页面
    function quick(e){
        var _this = e;
        var forcePreSet = _this.parents('.sort_new').attr('forcePreSet')||'';
        var freepreset = _this.parents('.sort_new').attr('freepreset')||'';
        var tableName = _this.parents('.sort_new').attr('tableName')||'';
        if(freepreset == '1'&&(forcePreSet == '2'||forcePreSet == '3'||forcePreSet == '4')){
            if(forcePreSet == '2'){
                var calc = '此工作要求强制输入前缀，确定进入新建向导？';
            }else if(forcePreSet == '3'){
                var calc = '此工作要求强制输入后缀，确定进入新建向导？';
            }else if(forcePreSet == '4'){
                var calc = '此工作要求强制输入前缀和后缀，确定进入新建向导？';
            }
            var r = confirm(calc);
            if (r==true){
                $.ajax({
                    url:'/userCountPer',
                    dataType:'json',
                    type:'get',
                    success:function(res){
                        if(res.flag){
                            var flowId=_this.attr('flowId');
                            if(tableName == 'BUDGETTYPE'){
                                $.popWindow("/workflow/work/newflowguider?flowId="+flowId+'&flowStep=1&tableName=budget&prcsId=1','<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
                            }else{
                                $.popWindow("/workflow/work/newflowguider?flowId="+flowId+'&flowStep=1&prcsId=1','<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
                            }

                        }else{
                            $.layerMsg({content:'人数达到上限，不能新建',icon:6})
                        }
                    }
                })
            }else{

            }
        }else{
            $.ajax({
                url:'/userCountPer',
                dataType:'json',
                type:'get',
                success:function(res){
                    if(res.flag){
                        var flowId= _this.attr('flowId');
                        user_id='quick';
                        newWorkFlow(flowId,function (data) {
                            if(data.sortMainType=='BUDGETTYPE'){
                                $.popWindow("/workflow/work/workform?opflag=1&flowId="+flowId+'&type=new&flowStep=1&prcsId=1&tableName=budget&runId='+data.flowRun.runId,'<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
                            }else{
                                $.popWindow("/workflow/work/workform?opflag=1&flowId="+flowId+'&type=new&flowStep=1&prcsId=1&runId='+data.flowRun.runId,'<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
                            }

                        })
                    }else{
                        $.layerMsg({content:'人数达到上限，不能新建',icon:6})
                    }
                }
            })
        }


    };
    //点击新建向导
    $(document).on('click','.xiangdao',function(){
        var _this = $(this);
        var tableName = _this.parents('.sort_new').attr('tableName')||'';
        $.ajax({
            url:'/userCountPer',
            dataType:'json',
            type:'get',
            success:function(res){
                if(res.flag){
                    var flowId=_this.attr('flowId');
                    if(tableName == 'BUDGETTYPE'){
                        $.popWindow("/workflow/work/newflowguider?flowId="+flowId+'&flowStep=1&tableName=budget&prcsId=1','<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
                    }else{
                        $.popWindow("/workflow/work/newflowguider?flowId="+flowId+'&flowStep=1&prcsId=1','<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
                    }
                }else{
                    $.layerMsg({content:'人数达到上限，不能新建',icon:6})
                }
            }
        })

    })

</script>

</body>
</html>
